{extend name="public/main" /}

{block name="css"}
<style>
    .layui-form-switch{margin-top: 0;}
</style>
{/block}

{block name="body"}

<div class="layui-fluid">
    <form action="{:url('sort')}" method="post">
        <table class="layui-table" style="margin-top: 0;">
            <tr>
                <th style="width: 45px;"><b>排序</b></th>
                <th><b>权限名</b></th>
                <!--<th><b>权限标识</b></th>-->
                <th><b>菜单URL</b></th>
                <th><b>菜单显示</b></th>
                <th><b>是否有效</b></th>
                <th><b>备注</b></th>
                <th style="padding: 0 15px;line-height: 40px;"><b>操作</b>
                    <span style="float: right">
                        <!--<a href="{:url('add')}" data-width="1100px" data-height="800px" class="layui-btn layui-btn-sm xn_open" title="添加权限">添加权限</a>-->
                        <a href=""  class="layui-btn layui-btn-sm" title="刷新">刷新</a>
                    </span>
                </th>
            </tr>

            <tbody>
            {foreach name="list" item="vo"}
            <tr>
                <td><input type="text" name="{$vo.id}" placeholder="排序" autocomplete="off" class="layui-input" value="{$vo.sort}" style="width: 45px;height:24px;line-height:24px;color: #999;"></td>
                <td>{$vo._name}</td>
                <!--<td>{$vo.auth_name}</td>-->
                <td>{$vo.name}</td>
                <td class="layui-form">
                    {if condition="$vo['ismenu'] eq 1"}
                    <button type="button" class="layui-btn layui-btn-sm layui-btn-primary">显示</button>
                    {else}
                    <button type="button" class="layui-btn layui-btn-sm layui-btn-danger">非菜单权限</button>
                    {/if}
                </td>
                <td class="layui-form">
                    {if condition="$vo['status'] eq 1"}
                    <button type="button" class="layui-btn layui-btn-sm layui-btn-primary">有效</button>
                    {else}
                    <button type="button" class="layui-btn layui-btn-sm layui-btn-danger">无效</button>
                    {/if}
                </td>
                <td>{$vo.remark}</td>
                <td>
                    <!--<a href="{:url('add',array('pid'=>$vo['id']))}" data-width="1100px" data-height="800px" class="layui-btn layui-btn-xs xn_open" title="添加子权限">-->
                        <!--<i class="layui-icon layui-icon-addition"></i>添加子权限-->
                    <!--</a>-->
                    <!--<a href="{:url('edit',array('id'=>$vo['id']))}" data-width="1100px" data-height="800px" title="{$vo.title}" class="layui-btn layui-btn-normal layui-btn-xs xn_open">-->
                        <!--<i class="layui-icon layui-icon-edit"></i>修改-->
                    <!--</a>-->
                    <!--<a href="{:Url('delete',array('id'=>$vo['id']))}" title="确认要删除【{$vo.title}】吗？" class="layui-btn layui-btn-danger layui-btn-xs xn_delete">-->
                        <!--<i class="layui-icon layui-icon-delete"></i>删除-->
                    <!--</a>-->
                </td>
            </tr>
            {/foreach}
            <tr>
                <td colspan="5">
                    <!--<button type="submit" class="layui-btn">排序</button>-->
                </td>
            </tr>
            </tbody>
        </table>
    </form>
</div>
{/block}

{block name="js"}
<script>
    layui.form.on('switch(ismenu)', function(data){
        //layer.tips('开关checked：'+ (this.checked ? 'true' : 'false'), data.othis)
        var val = this.checked ? 1 : 0;
        var id = $(this).attr('data-id');
        var url = "{:url('edit')}";
        $.post(url,{id:id,ismenu:val},function (res) {
            console.log(res);
            layer.tips(res.msg, data.othis);
        },'json')
    });
    layui.form.on('switch(status)', function(data){
        //layer.tips('开关checked：'+ (this.checked ? 'true' : 'false'), data.othis)
        var val = this.checked ? 1 : 0;
        var id = $(this).attr('data-id');
        var url = "{:url('edit')}";
        $.post(url,{id:id,status:val},function (res) {
            console.log(res);
            layer.tips(res.msg, data.othis);
        },'json')
    });
</script>
{/block}